﻿package extremefx.tools {
	public function gcLock(pTarget:Object, pLock:Boolean):void {
		Utils.lock(pTarget, pLock);
	}
}

import flash.utils.Dictionary;
import flash.events.IEventDispatcher;
import flash.events.Event;

class Utils {
	private static var _activeLocks:Dictionary = new Dictionary();
	
	public static function lock(pTarget:Object, pLock:Boolean):void {
		if (pLock) {
			if (pTarget is IEventDispatcher) { 
				pTarget.addEventListener("EFX_EVENT", _nullListener, false, 0, false);
				 
			} else { 
				_activeLocks[pTarget] = true; 
			}
			
		} else {
			if (pTarget is IEventDispatcher) { 
				pTarget.removeEventListener("EFX_EVENT", _nullListener);
			}
			
			delete(_activeLocks[pTarget]);
		}
	}
	
	private static function _nullListener(evt:Event):void {};
}